home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok44.lha
/
GRandom
/
grandom.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
902b
|
48 lines
(**********************************************************************
:Program. GRandom
:Contents. Erzeugt eine standardnormalverteilte Zufallszahl
:Author. Steffen Reith
:Address. Hessenstr. 64, D-8700 Würzburg
:Language. Modula-2
:Translator. M2Amiga A+L V3.2d
**********************************************************************)
IMPLEMENTATION MODULE GRandom;
FROM MathLib0 IMPORT ln,sqrt;
FROM RandomNumber IMPORT PutSeed,Random;
VAR seed[0DFF006H]:LONGINT;
PROCEDURE GRND():REAL;
VAR p:REAL;
PROCEDURE Transform(p:REAL):REAL;
CONST a0=2.31;b1=0.99;
a1=0.27;b2=0.045;
VAR t,h:REAL;
BEGIN
t:=sqrt(ln(1.0/(p*p)));
h:=(a0+a1*t)/(1.0+t*(b1+b2*t));
RETURN t-h
END Transform;
BEGIN
p:=Random();
IF p<=0.5 THEN
RETURN Transform(p)
ELSE
p:=1.0-p;
RETURN -1.0*Transform(p)
END
END GRND;
BEGIN
PutSeed(ABS(seed));
END GRandom.